#include "stdafx.h"
#include "StructureAndConst.h"
#include "flydx9.h"
#include "SpriteCombined.h"
#include "SpriteMultiFrame.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

SpriteCombined::SpriteCombined(const vector<BaseDispSprite*>& listSprite,int nLayer):
BaseDispSprite(nLayer)
{
	m_listSprite.assign(listSprite.begin(),listSprite.end());
}
SpriteCombined::SpriteCombined(int nLayer,bool bDrawOnView,bool bCycle):
	BaseDispSprite(nLayer,bDrawOnView,bCycle)
{

}
SpriteCombined::~SpriteCombined()
{
	vector<BaseDispSprite*>::iterator it;
	for (it=m_listSprite.begin();it!=m_listSprite.end();it++){
		SAFE_DELETE (*it)
	}
}
void SpriteCombined::AddSprite(BaseDispSprite* pSprite)
{
	m_listSprite.push_back(pSprite);
}
bool SpriteCombined::Draw(DWORD dwCurrentTime)
{
	if(!BaseDispSprite::UpdatePosByLgSprite()) return false;

	vector<BaseDispSprite*>::iterator it;
	for (it=m_listSprite.begin();it!=m_listSprite.end();it++)
	{
		D3DXVECTOR2 posOriginal=(*it)->m_vPosition;
		(*it)->m_vPosition+=m_vPosition;
		(*it)->Draw(dwCurrentTime);
		(*it)->m_vPosition=posOriginal;
	}
	return true;
}
